package com.itfreer.cms.service.module;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.cms.dao.module.SensitiveDao;
import com.itfreer.cms.entity.module.SensitiveEntity;
import com.itfreer.form.api.BaseDao;
import com.itfreer.form.api.imp.DictionaryServiceImp;
import com.itfreer.form.dictionary.base.DictionaryItem;

/**
 * 敏感词管理实现类
 */
@Component("sensitiveServicelmp")
public class SensitiveServicelmp extends DictionaryServiceImp<SensitiveEntity> implements SensitiveService {

	@Autowired
	private SensitiveDao sensitiveDao;

	@Override
	protected BaseDao<SensitiveEntity> getDao() {
		return sensitiveDao;
	}

	@Override
	public String getDictionaryName() {
		return "cms_sensitive";
	}

	@Override
	protected DictionaryItem convert(SensitiveEntity t) {
		DictionaryItem item = new DictionaryItem();
		item.setId(t.getId());
		item.setCode(t.getId());
		item.setDisplay(t.getSensitive());
		item.setInfo(t.getReplace());
		item.setOrder(1);
		if (t.getState() != null && t.getState().equals("1")) {
			item.setValid(true);
		} else {
			item.setValid(false);
		}
		return item;
	}

	@Override
	protected String getDictionaryFields() {
		return "id,sensitive,replace,state";
	}

}
